package controllers

import (
	"github.com/astaxie/beego"
	"github.com/astaxie/beego/httplib"
	"strconv"
	"encoding/json"
	"xiaoercaidan/publicResources/models"
	"fmt"
)

type ShopController struct {
	beego.Controller
}

// @Title ShopDetail
// @Description 店铺详情
// @Param   shopId    patch int64  true  string       "店铺ID"
// @router /shopDetail [get]
func (this *ShopController) ShopDetail()  {
	hostStr := "http://"+beego.AppConfig.String("basehost")+":"+beego.AppConfig.String("baseport")
	var shopId,_ = this.GetInt64("shopId",0)
	var BaseResult = new(models.BaseResult)
	if(shopId <= 0){
		BaseResult.Code = 100
		BaseResult.Msg = "shopId参数不正确"
		this.Data["json"] = &BaseResult
		this.ServeJSON()
		return
	}
	req := httplib.Get(hostStr+"/v1/apis/shop/queryShopById")
	fmt.Println(hostStr+"/v1/apis/shop/queryShopById")
	req.Param("shopId", strconv.FormatInt(shopId, 10))
	resp, err := req.String()

	if (err == nil) {
		var mapStr = make(map[string]interface{})

		json.Unmarshal([]byte(resp), &mapStr)

		this.Data["json"] = mapStr

	}

	this.ServeJSON()
}